package pl.koziolekweb.szkola.DBTryCatch2;

// DB-TryCatch2/WhatIsIt.java
 
public class WhatIsIt {

    private EType typ;

    private int    argint;
    private double argdouble;
    private String argstring;

    public WhatIsIt(String s) {

        if (s == null) {
            typ = EType.N;
            return;
        }

        s = s.trim();

        if (s.equals("")) {
            typ = EType.E;
            return;
        }

        try {
            argint = Integer.parseInt(s);
            typ = EType.I;
            return;
        } catch (NumberFormatException ignore) { };

        try {
            argdouble = Double.parseDouble(s);
            typ = EType.R;
            return;
        } catch (NumberFormatException ignore) { };

        argstring = s;
        typ = EType.S;
    }

    public EType    getTyp()    { return typ; }
    public int    getInt()    { return argint; }
    public double getDouble() { return argdouble; }
    public String getString() { return argstring; }
}